package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Reference
    private SetMealService setMealService;

    /**
     *     /setmeal/getSetmeal.do
          查找全部套餐
     */
    @RequestMapping("/getSetmeal")
    public Result getSetmeal() {
        try {
            List<Setmeal> setmealList = setMealService.getSetmeal();
            return new Result(true, MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmealList);
        } catch (Exception e) {
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }


    /**
     *  查找套餐详情-检查组-检查项
     * setmeal/findById.do?id=" + id
     */
    @RequestMapping("/findById")
    public Result findById(Integer id){
        try{
            Setmeal setmeal=setMealService.findSetMealById(id);
            return new Result(true,MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmeal);
        }catch (Exception e){
            return  new Result(false,MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }
}
